package ui.panel
{

	import flash.display.Bitmap;
	import flash.utils.ByteArray;

	import globals.ButtonType;
	import globals.Global;

	import net.message.CG_Hero_TraitUpMessage;

	import ui.component.GameTextField;
	import ui.component.TextButton;
	import ui.panel.warriorLevelups.WarriorLevelUpNeed;
	import ui.panel.warriorLevelups.WarriorNextInfo;
	import ui.panel.warriorLevelups.WarriorNowInfo;

	import util.Long;
	import util.TextStyle;
	import util.UIUtil;

	/**
	 * 英雄晋级
	 * @author luguobin
	 */
	public class WarriorLevelUpPanel extends BasePanel
	{
		private var _curHeroInfo:WarriorNowInfo;
		private var _nextHeroInfo:WarriorNowInfo;
		private var _conditionText:GameTextField; //条件
		private var _coinText:GameTextField; //消耗金币
		private var _btn:TextButton;
		private var _img:Bitmap;

		public function WarriorLevelUpPanel()
		{
			super();
			pid = PanelType.WARRIOR_LEVELUP_PANEL;
			updateTitle("英雄晋级");
		}

		override protected function initUI():void
		{
			super.initUI();

			_curHeroInfo = new WarriorNowInfo();
			_curHeroInfo.x = 60;
			_curHeroInfo.y = 50;
			this.addChild(_curHeroInfo);

			_nextHeroInfo = new WarriorNowInfo();
			_nextHeroInfo.x = 415;
			_nextHeroInfo.y = 50;
			this.addChild(_nextHeroInfo);

			_img = new Bitmap();
			_img.x = 280;
			_img.y = 80;
			this.addChild(_img);

			_conditionText = new GameTextField();
			_conditionText.defaultTextFormat = TextStyle.getTextFormat();
			_conditionText.wordWrap = _conditionText.multiline = true;
			_conditionText.width = 200;
			_conditionText.x = 250;
			_conditionText.y = 210;
			this.addChild(_conditionText);

			_coinText = new GameTextField();
			_coinText.defaultTextFormat = TextStyle.getTextFormat(0xFFFFFF, 12, true);
			_coinText.x = 250;
			_coinText.y = 300;
			this.addChild(_coinText);

			_btn = UIUtil.getTextButton(0, "晋级", ButtonType.BUTTON_BLUE, btnHandle);
			_btn.x = 275;
			_btn.y = 330;
			this.addChild(_btn);

			//TODO：测试
			update();
		}

		private function btnHandle(button:TextButton):void
		{

		}

		public function initData(heroId:Long):void
		{
			/////
			var message:CG_Hero_TraitUpMessage = new CG_Hero_TraitUpMessage();
			message.writeMessage(heroId);
		}

		public function update():void
		{
			_img.bitmapData = Global.assetsManager.getAssetsAsBitmapData("tower1b");
			_conditionText.htmlText = "转职需求：<br>弓箭手等级达到 10级";
			_coinText.mytext = "消耗  200";
		}
	}
}